﻿using System;

namespace YFurion.Application
{
    /// <summary>
    /// A shortcut of <see cref="EntityDto{TKey}"/> for most used key type (<see cref="long"/>).
    /// </summary>
    [Serializable]
    public class EntityDto : EntityDto<long>, IEntityDto
    {
        public override long Id { get; set; }

        /// <summary>
        /// Creates a new <see cref="EntityDto"/> object.
        /// </summary>
        public EntityDto()
        {

        }

        /// <summary>
        /// Creates a new <see cref="EntityDto"/> object.
        /// </summary>
        /// <param name="id">Id of the entity</param>
        public EntityDto(long id)
            : base(id)
        {
        }
    }

    /// <summary>
    /// Implements common properties for entity based DTOs.
    /// </summary>
    /// <typeparam name="TKey">Type of the key</typeparam>
    [Serializable]
    public class EntityDto<TKey> : BaseDto, IEntityDto<TKey>
    {
        /// <summary>
        /// Id of the entity.
        /// </summary>
        public virtual TKey Id { get; set; }

        /// <summary>
        /// Creates a new <see cref="EntityDto{TKey}"/> object.
        /// </summary>
        public EntityDto()
        {
        }

        /// <summary>
        /// Creates a new <see cref="EntityDto{TKey}"/> object.
        /// </summary>
        /// <param name="id">Id of the entity</param>
        public EntityDto(TKey id)
        {
            Id = id;
        }

        public override string ToString()
        {
            return $"[{GetType().Name}#{Id}]";
        }
    }
}
